<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<BusinessTransactionResponse>
			<xsl:for-each select="insupost-response">
				<BusinessTransaction>
					<kind>Surrender Inquiry</kind>
					<transationId>
						<xsl:value-of select="response-head/trans-id" />
					</transationId>
					<transationDate>
						<xsl:value-of select="concat(substring(string(response-head/trans-date),1,4),'-',substring(string(response-head/trans-date),5,2),'-',substring(string(response-head/trans-date),7,2),' ',substring(string(response-head/trans-time),1,2),':',substring(string(response-head/trans-time),3,2),':',substring(string(response-head/trans-time),5,2))" />
					</transationDate>
					<partnerCode>WANGXIAO</partnerCode>
					<Properties>
						<xsl:for-each select="response-policy-value-query">
							<Property kind="availableMoney" name="可支取支取金额">
								<xsl:attribute name="value"><xsl:value-of select="column3" /></xsl:attribute>
							</Property>
							<Property kind="serviceCharge" name="手续费">
								<xsl:attribute name="value"><xsl:value-of select="column2" /></xsl:attribute>
							</Property>
						</xsl:for-each>
					</Properties>
				</BusinessTransaction>
				<TransactionResult>
					<xsl:choose>
						<xsl:when test="/insupost-response/response-head/trans-result = 0">
							<resultCode>SUCCESS</resultCode>
						</xsl:when>
						<xsl:otherwise>
							<resultCode>FAILURE</resultCode>
							<ResultInfos>
								<xsl:choose>
									<xsl:when test="response-policy-value-query/errors != ''">
										<xsl:for-each select="response-policy-value-query/errors">
											<ResultInfo>
												<infoCode>
													<xsl:value-of select="error/error-code" />
												</infoCode>
												<infoCodeMessage>
													<xsl:value-of select="error/error-desc" />
												</infoCodeMessage>
											</ResultInfo>
										</xsl:for-each>
									</xsl:when>
								</xsl:choose>
								<xsl:choose>
									<xsl:when test="response-head/validity-errors != ''">
										<xsl:for-each select="response-head/validity-errors">
											<ResultInfo>
												<infoCode>
													<xsl:value-of select="validity-error/error-code" />
												</infoCode>
												<infoCodeMessage>
													<xsl:value-of select="validity-error/error-desc" />
												</infoCodeMessage>
											</ResultInfo>
										</xsl:for-each>
									</xsl:when>
								</xsl:choose>
							</ResultInfos>
						</xsl:otherwise>
					</xsl:choose>
				</TransactionResult>
				<xsl:choose>
					<xsl:when test="/insupost-response/response-head/trans-result = 0">
						<InsurancePolicy>
							<xsl:for-each select="response-policy-value-query">
								<externalReference>
									<xsl:value-of select="policy-code" />
								</externalReference>
								<Properties>
									<Property kind="policyValue" name="保单价值">
										<xsl:attribute name="value"><xsl:value-of select="policy-value" /></xsl:attribute>
									</Property>
									<Property kind="policyStatus" name="保单状态">
										<xsl:attribute name="value"><xsl:value-of select="policy-status" /></xsl:attribute>
									</Property>
									<xsl:for-each select="/insupost-response/response-policy-value-query/products/product">
										<funds>
											<xsl:for-each select="funds/fund">
												<fund>
													<accountCode>
														<xsl:value-of select="fund-code" />
													</accountCode>
													<Properties>
														<Property kind="units" name="单位数">
															<xsl:attribute name="value"><xsl:value-of select="units" /></xsl:attribute>
														</Property>
														<Property kind="fundPrice" name="单位价格">
															<xsl:attribute name="value"><xsl:value-of select="off-price" /></xsl:attribute>
														</Property>
														<Property kind="priceDate" name="单位价格日期">
															<xsl:attribute name="value"><xsl:value-of select="pricing-date" /></xsl:attribute>
														</Property>
													</Properties>
												</fund>
											</xsl:for-each>
										</funds>
									</xsl:for-each>
								</Properties>
							</xsl:for-each>
						</InsurancePolicy>
					</xsl:when>
				</xsl:choose>
			</xsl:for-each>
		</BusinessTransactionResponse>
	</xsl:template>
</xsl:stylesheet>
